package model

func GetArticle(page int,size int) (obj []ArticleDb , err error) {
	obj = make([]ArticleDb,0)

	return obj, db.Limit(size).Offset((page-1)*size).Find(&obj).Error
}


func GetArticleCount() (count int64, err error) {
	count = int64(0)
	return count,db.Table("t_article").Count(&count).Error
}

func CreateArticle(obj ArticleDb)( err error) {
	return db.Create(&obj).Error
}

func LikeArticle(obj LikeDb) (err error) {
	return db.Create(&obj).Error
}

func CheckLike(userId int64,likeId uint64) (obj LikeDb ,err error) {
	return obj,db.Where("user_id=? AND like_id=?",userId,likeId).Find(&obj).Error
}